package com.wu.advapplication.utils;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.wu.advapplication.R;

public class MyDialog extends Dialog implements
        View.OnClickListener {
    public String TAG = "BaseDialog";
    public String mDialogMsg;
    public Context context;
    public TextView mTitle, mContent;
    public Button okButton, noButton;


    /**
     * @param context
     * @param theme
     * @param DialogMsg
     */
    public MyDialog(Context context, int theme, String DialogMsg) {
        super(context, theme);
        this.context = context;
        this.mDialogMsg = DialogMsg;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_style);
        mTitle = (TextView) findViewById(R.id.d_tv_title);
        mContent = (TextView) findViewById(R.id.d_tv_content);
        okButton = findViewById(R.id.d_btn_ok);
        noButton = findViewById(R.id.d_btn_no);
        okButton.setOnClickListener(this);
        noButton.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.d_btn_ok:
                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
                this.cancel();
                break;

            case R.id.d_btn_no:
                this.cancel();
                break;
        }
    }
}
